package com.kerrykidz.scminvoicing.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kerrykidz.scminvoicing.dao.mapper.ScmPurOrderEntityMapper;
import com.kerrykidz.scminvoicing.dao.mapper.ScmPurordPrdEntityMapper;
import com.kerrykidz.scminvoicing.dao.mapper.ScmSupAgmEntityMapper;
import com.kerrykidz.scminvoicing.dao.model.GblScmPrdEntity;
import com.kerrykidz.scminvoicing.dao.model.ScmPurOrderEntity;
import com.kerrykidz.scminvoicing.dao.model.ScmPurordPrdEntity;
import com.kerrykidz.scminvoicing.dao.model.ScmSupAgmEntity;
import com.kerrykidz.scminvoicing.dao.model.ScmSupEntity;
import com.kerrykidz.scminvoicing.dao.model.ScmSupPrdEntity;
import com.kerrykidz.scminvoicing.service.IScmPurOrderService;
import com.rdp.framework.exception.RDPException;
@Service
public class ScmPurOrderServiceImpl implements IScmPurOrderService {
	@Autowired
	private ScmPurOrderEntityMapper scmPurOrderEntityMapper;
	@Autowired
	private ScmPurordPrdEntityMapper scmPurordPrdEntityMapper;
	@Autowired
	private ScmSupAgmEntityMapper scmSupAgmEntityMapper;
	@Override
	public List<ScmPurOrderEntity> findScmPurOrderEntityList (
			ScmPurOrderEntity scmPurOrder) throws RDPException{
		scmPurOrder.setIspaging(true);
		return scmPurOrderEntityMapper.findScmPurOrder(scmPurOrder);
	}

	@Override
	public ScmPurOrderEntity getScmPurOrderById(String pkPurordId) {
		return scmPurOrderEntityMapper.getScmPurOrderById(pkPurordId);
	}

	@Override
	public void addScmPurOrder(ScmPurOrderEntity scmPurOrder) {
		scmPurOrderEntityMapper.addScmPurOrder(scmPurOrder);
	}

	@Override
	public void updateScmPurOrder(ScmPurOrderEntity scmPurOrder) {
		scmPurOrderEntityMapper.updateScmPurOrder(scmPurOrder);
	}
	
	@Override
	public List<ScmPurordPrdEntity> findPurOrderPrdByOrderId(String fkPurordId,String supplyId) {
		return scmPurordPrdEntityMapper.findPurOrderPrdByOrderId(fkPurordId,supplyId);
	}

	@Override
	public void addPurOrderPrdBatch(List<ScmPurordPrdEntity> scmPurordPrdList) {
		scmPurordPrdEntityMapper.addPurOrderPrdBatch(scmPurordPrdList);
	}

	@Override
	public void insertPurOrderPrd(ScmPurordPrdEntity scmPurordPrdEntity)
			throws RDPException {
		scmPurordPrdEntityMapper.insertPurOrderPrd(scmPurordPrdEntity);

	}

	public void delPurOrderPrdByOrderId(String fkPurordId) throws RDPException {
		scmPurordPrdEntityMapper.delPurOrderPrdByOrderId(fkPurordId);

	}
	

	public ScmPurordPrdEntity getPurOrderPrdByOrderIdAndPrdId(
			String fkPurordId, String fkPrdId) {
		return scmPurordPrdEntityMapper.getPurOrderPrdByOrderIdAndPrdId(fkPurordId, fkPrdId);
	}

	@Override
	public void delPurOrderPrdByOrderIdAndPrdId(String fkPurordId,
			String fkPrdId) throws RDPException {
		scmPurordPrdEntityMapper.delPurOrderPrdByOrderIdAndPrdId(fkPurordId, fkPrdId);
		
	}

	@Override
	public List<ScmSupEntity> PurOrderSupplyListBySprdId(String sprdId) {
		return scmPurOrderEntityMapper.PurOrderSupplyListBySprdId(sprdId);
	}

	@Override
	public List<ScmSupAgmEntity> findsupAgmListbyPrdId(String fkPrdId) {
		return scmSupAgmEntityMapper.findsupAgmListbyPrdId(fkPrdId);
	}

	@Override
	public List<ScmSupEntity> PurOrderSupplyList(String fkBranId) {
		return scmPurOrderEntityMapper.PurOrderSupplyList(fkBranId);
	}

	@Override
	public ScmSupEntity PurOrderSupplyBySprdIdandSupId(String pkSupId,
			String sprdId) {
		return scmPurOrderEntityMapper.PurOrderSupplyBySprdIdandSupId(pkSupId,sprdId);
	}

	@Override
	public List<ScmPurordPrdEntity> findPurOrderPrdListByOrderId(
			String fkPurordId) {
		return scmPurordPrdEntityMapper.findPurOrderPrdListByOrderId(fkPurordId);
	}

	@Override
	public List<GblScmPrdEntity> findProductListJoinOrderPrd(
			GblScmPrdEntity entity) throws RDPException {
		return scmPurordPrdEntityMapper.findProductListJoinOrderPrd(entity);
	}

	@Override
	public void delPurOrderByOrderId(String pkPurordId) {
		scmPurOrderEntityMapper.delPurOrderByOrderId(pkPurordId);
	}

	@Override
	public List<ScmSupPrdEntity> getPurOrderPrdBySupId(String fkPurordId,String fksupplyId,
			String fkBranId) throws RDPException {
		return scmPurordPrdEntityMapper.getPurOrderPrdBySupId(fkPurordId,fksupplyId, fkBranId);
	}

	@Override
	public ScmSupEntity getScmSupBysupId(String pkPurordId) {
		return scmPurOrderEntityMapper.getScmSupBysupId(pkPurordId);
	}


}
